import 'package:flutter/material.dart';
import 'package:flutter_widget/custom/custom_appbar.dart';
import 'package:left_scroll_actions/left_scroll_actions.dart';

// ignore: must_be_immutable
class LeftScrollActions extends StatefulWidget {
  String name;
  LeftScrollActions({Key? key, required this.name}) : super(key: key);

  @override
  _LeftScrollActionsState createState() => _LeftScrollActionsState();
}

class _LeftScrollActionsState extends State<LeftScrollActions> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: CustomAppbar(widget.name, Theme.of(context).primaryColor),
        backgroundColor: const Color(0xFFf5f5f4),
        body: ListView(
          children: <Widget>[
            LeftScroll(
              buttonWidth: 80,
              child: Container(
                height: 60,
                color: Colors.white,
                alignment: Alignment.center,
                child: const Text('👈 Try Scroll Left'),
              ),
              buttons: <Widget>[
                LeftScrollItem(
                  text: 'delete',
                  color: Colors.red,
                  onTap: () {
                    print('delete');
                  },
                ),
                LeftScrollItem(
                  text: 'Edit',
                  color: Colors.orange,
                  onTap: () {
                    print('edit');
                  },
                ),
              ],
              onTap: () {
                print('tap row');
              },
            ),
            LeftScroll(
              child: Container(
                height: 60,
                color: Colors.white.withOpacity(0.8),
                alignment: Alignment.center,
                child: const Text('If opacity is not 1.0,may cause problem.'),
              ),
              buttons: const <Widget>[
                LeftScrollItem(
                  text: 'delete',
                  color: Colors.red,
                ),
                LeftScrollItem(
                  text: 'Edit',
                  color: Colors.orange,
                ),
              ],
            ),
            CupertinoLeftScroll(
              buttonWidth: 60,
              child: Container(
                height: 60,
                color: Colors.white,
                alignment: Alignment.center,
                child: const Text('👈 Try Scroll Left(iOS style)'),
              ),
              buttons: <Widget>[
                LeftScrollItem(
                  text: 'Delete',
                  color: Colors.red,
                  onTap: () {
                    print('delete');
                  },
                ),
                LeftScrollItem(
                  text: 'Edit',
                  color: Colors.orange,
                  onTap: () {
                    print('edit');
                  },
                ),
              ],
              onTap: () {
                print('tap row');
              },
            ),
            CupertinoLeftScroll(
              buttonWidth: 60,
              bounce: true,
              child: Container(
                height: 60,
                color: Colors.white,
                alignment: Alignment.center,
                child: const Text('👈 Try Scroll Left(iOS style with bounce)'),
              ),
              buttons: <Widget>[
                LeftScrollItem(
                  text: 'Delete',
                  color: Colors.red,
                  onTap: () {
                    print('delete');
                  },
                ),
                LeftScrollItem(
                  text: 'Edit',
                  color: Colors.orange,
                  onTap: () {
                    print('edit');
                  },
                ),
              ],
              onTap: () {
                print('tap row');
              },
            ),
            CupertinoLeftScroll(
              opacityChange: true,
              buttonWidth: 80,
              child: Container(
                height: 60,
                color: Colors.white,
                alignment: Alignment.center,
                child: const Text('👈 Try iOS style with opa change'),
              ),
              buttons: <Widget>[
                LeftScrollItem(
                  text: 'delete',
                  textColor: Colors.red,
                  color: Colors.red.withOpacity(0),
                  onTap: () {
                    print('delete');
                  },
                ),
                LeftScrollItem(
                  text: 'Edit',
                  textColor: Colors.orange,
                  color: Colors.orange.withOpacity(0),
                  onTap: () {
                    print('edit');
                  },
                ),
              ],
              onTap: () {
                print('tap row');
              },
            ),
          ],
        ));
  }
}
